{%- extends "base.html" %}

{%- block title %}
{% trans %}Fetched accounts{% endtrans %}
{%- endblock %}

{%- block subtitle %}
{{ user }}
{%- endblock %}

{%- block main_action %}
<a class="btn btn-primary float-right" href="{{ url_for('.fetch_create', user_email=user.email) }}">{% trans %}Add an account{% endtrans %}</a>
{%- endblock %}

{%- block content %}
{%- call macros.table(order='[[1,"asc"]]') %}
<thead>
  <tr>
    <th data-orderable="false">{% trans %}Actions{% endtrans %}</th>
    <th>{% trans %}Endpoint{% endtrans %}</th>
    <th>{% trans %}Username{% endtrans %}</th>
    <th>{% trans %}Keep emails{% endtrans %}</th>
    <th>{% trans %}Rescan emails{% endtrans %}</th>
    <th>{% trans %}Folders{% endtrans %}</th>
    <th>{% trans %}Last check{% endtrans %}</th>
    <th>{% trans %}Status{% endtrans %}</th>
    <th>{% trans %}Created{% endtrans %}</th>
    <th>{% trans %}Last edit{% endtrans %}</th>
  </tr>
</thead>
<tbody>
  {%- for fetch in user.fetches %}
  <tr>
    <td>
      <a href="{{ url_for('.fetch_edit', fetch_id=fetch.id) }}" title="{% trans %}Edit{% endtrans %}"><i class="fa fa-pencil-alt"></i></a>&nbsp;
      <a href="{{ url_for('.fetch_delete', fetch_id=fetch.id) }}" title="{% trans %}Delete{% endtrans %}"><i class="fa fa-trash"></i></a>
    </td>
    <td>{{ fetch.protocol }}{{ 's' if fetch.tls else '' }}://{{ fetch.host }}:{{ fetch.port }}</td>
    <td>{{ fetch.username }}</td>
    <td data-sort="{{ fetch.keep }}">{% if fetch.keep %}{% trans %}yes{% endtrans %}{% else %}{% trans %}no{% endtrans %}{% endif %}</td>
    <td data-sort="{{ fetch.scan }}">{% if fetch.scan %}{% trans %}yes{% endtrans %}{% else %}{% trans %}no{% endtrans %}{% endif %}</td>
    <td>{{ fetch.folders | join(',') }}</td>
    <td>{{ fetch.last_check | format_datetime or '-' }}</td>
    <td>{{ fetch.error or '-' }}</td>
    <td data-sort="{{ fetch.created_at or '0000-00-00' }}">{{ fetch.created_at | format_date }}</td>
    <td data-sort="{{ fetch.updated_at or '0000-00-00' }}">{{ fetch.updated_at | format_date }}</td>
  </tr>
  {%- endfor %}
</tbody>
{%- endcall %}
{%- endblock %}
